def isprime( n ):
  d = 2
  if n == 0:
    return True
  if n == 1:
    return False
  while ( d*d < n+1 ):
    if ( n % d == 0 ):
      return False
    d += 1
  return True
